<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="./jquery-3.4.1.min.js"></script>
    <script type="text/javascript" src="./jquery-3.4.1.js"></script>
</head>
<body>
    <textarea name="nextIndex" id="nextIndex" cols="22" rows="20"></textarea>
    <textarea name="desc" id="desc" cols="22" rows="20"></textarea>
    <input type="button" onclick="go()" value="提交新队列">
</body>
<script>


    function go() {
        var textareaContents = $('#desc').val();
        console.log(textareaContents)
        $.ajax({
            url:"/changeOrder",
            type:"post",
            data:textareaContents,//第一个textareaContents值文本框的Id，用jquery方式的AJAX提交，这个Id必须要
            dataType:"json",
            headers	:{'Content-Type': 'application/json'},
            success:function(res){
                console(123)
                console.log(res)
                alert(res)
            },
            complete: function (xhr) {
                // 不管是成功还是失败都是完成，都会执行这个 complete 函数
                console.log('complete', xhr)
                alert(xhr.responseText)
            }
        })
    }

    $(document).ready(function(){
        //服务端值班队列
        $.ajax({
            url:"/listOrderList",
            type:"get",
            success:function(data){
                console.log(data)
                $('#desc').val(data)
            }
        })
        $.ajax({
            url:"/getNextIndex",
            type:"get",
            success:function(data){
                console.log(data)
                $('#nextIndex').val('下周值周:'+data.name)
            }
        })
    })

</script>
</html>